const data = [
{ name: "js", price: 100 },
{ name: "mysql", price: 212 },
{ name: "vue.js", price: 398 }
];

const Tool = {
  // 获取某一列
  getColumn (filed) {
    return function(item, index, arr) {
      // return filed ?  item[filed] : item
      return item[filed]
    }
  }


}

class Lesson {
  constructor(data) {
    this.model = data
  }

  static createBatch(data) {
   return data.map(item => new Lesson(item))
 }

 static MaxPrice(lessons) {
  return lessons.sort((a, b) => b.model.price - a.model.price)[0].model.price
}


static getColumn (filed) {
    return function(item, index, arr) {
      return item.model[filed]
    }
  }

  // retType, row(一行), column(一列) ，one(一个单元格)
  static MaxPrice2(lessons, field  = 'price',  retType='row') {
    return lessons.map(this.getColumn(field))
  }

  
  static MaxPrice3(lessons) {
    var field  = 'price'
    var fn = function(item) {
      return field ? item.model[field] : item.model
    }
    return Math.max.apply(null, lessons.map(fn))
  }
  
}


// Object.assign(Lesson, Tool)
// 
const lessons = Lesson.createBatch(data);
console.log(lessons);
console.log(Lesson.MaxPrice(lessons));
console.log(Lesson.MaxPrice2(lessons));
console.log(Lesson.MaxPrice3(lessons));